﻿using System;
using System.Data;
using System.Data.OleDb;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAO
{
    public class DAORPTongKetMon:DataProvider
    {
       public static DataTable DanhSachList(string mamon, int hocky)
        {
            DataTable Bang;
            OleDbConnection ketNoi = Connect();
            string chuoilenh = "SELECT l.tenlop, (select count(HocSinh.MSHS) from HocSinh where HocSinh.MaLop = bd.MaLop) as sl,count(*) as soluongdat, round((soluongdat/siso)*100,2) as tyle FROM bangdiemmonhoc bd, lop l where bd.diemtb >= 5 and bd.Hocky =@hk and bd.mamon=@mamon and bd.Malop = l.Malop group by  bd.hocky,bd.mamon,bd.malop,l.tenlop,siso";
            OleDbCommand lenh = new OleDbCommand(chuoilenh, ketNoi);
            OleDbParameter values = new OleDbParameter("@hk", hocky);
            lenh.Parameters.Add(values);
            values = new OleDbParameter("@mamon", mamon);
            lenh.Parameters.Add(values);
            OleDbDataAdapter da = new OleDbDataAdapter();
            da.SelectCommand = lenh;
            DataSet ds = new DataSet();
            da.Fill(ds);
            Bang = ds.Tables[0];
            Disconnect();
            return Bang;
        }
    }
}




